package com.v5ba.annotation.async;

import com.v5ba.annotation.async.service.AsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("async")
public class AsyncController {
    @Autowired
    private AsyncService asyncService;

    @GetMapping("hello")
    public String hello(String name, String age) throws InterruptedException {
        System.out.println("开始");
        for (int i = 0; i < 10; i++) {
            asyncService.sayHello();
            //Thread.sleep(1000*2L);
        }
        System.out.println("结束");
        return name + age;
    }

}

